﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="background.Manager.login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <title>登录 - <%=ManagerConfig.bg("systemName") %></title>
    <link href="Styles/login.css" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
            var ch = document.documentElement.clientHeight;
            $(".main").css("margin-top", ((ch - 350) / 2) + "px");
            $("#loginPassword").keypress(function () {
                if (event.keyCode == 13) {
                    loginAction();
                }
            })
        })
        function loginAction() {
            var ln = $("#loginName"), lp = $("#loginPassword");
            if ($.trim(ln.val()).length == 0) {
                ln.focus();
                alert("请输入帐号"); return;
            }
            if ($.trim(lp.val()).length == 0) {
                lp.focus();
                alert("请输入密码"); return;
            }
            $.post("Action/fromData.ashx", {
                action: "login",
                loginName: $("#loginName").val(),
                password: $("#loginPassword").val()
            }, function (ret) {
                if (ret == 1) {
                    window.location.href = "main.aspx";
                } else {
                    alert("帐号或密码错误。");
                }
            })
        }
    </script>
</head>
<body>
    <div class="main">
        <strong>登入，<%=ManagerConfig.bg("systemName") %></strong>
        <div style="margin: 20px">
            <div class="sp">
                <label>帐号</label>
                <input type="text" class="text" id="loginName" />
            </div>
            <div class="sp">
                <label>密码</label>
                <input type="password" class="text" id="loginPassword" />
            </div>
            <div class="sp">
                <div style="float: left; line-height: 70px;"><a href="<%=ManagerConfig.sg("index") %>" target="_blank">网站首页</a></div>
                <div style="float: right;">
                    <input type="button" class="sbtn" value="登入系统" onclick="loginAction()" />
                </div>
            </div>
        </div>
    </div>
</body>
</html>
